<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>管理员登录</title>
    <link href="css/managerLogin.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<div class="container">
    <div class="left">
        <span>证书管理系统</span><br/>
        <span>Certificate Management System</span>
    </div>
    <div class="right">
        <div class="border">
            <p class="title">管理员登录</p>
            <form id="form1" action="" method="post">
                <table>
                    <tr>
                        <td>用户名：</td>
                        <td><input type="text" class="name" name="username"></td>
                    </tr>
                    <tr>
                        <td><span style="padding-right: 16px;">密</span><span>码：</span></td>
                        <td><input type="password" class="password" name="password"></td>
                    </tr>
                    <tr>
                        <td colspan="2"><button class="login" type="button" onclick="login()">登录</button></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<script src="js/jquery.js"></script>
<script>
    $(function () {
        $(".container").height($(window).height());
        $("table tr:not(:last)").each(function () {
            $(this).find("td:first").css("textAlign","right");
        });
        $("table tr:not(:last)").each(function () {
            $(this).find("td:last").css("textAlign","left");
        });
    });
    function login() {
        $.ajax({
            url: "http://test.shitongyiwu.com/cert/login/submit" ,
            type: "POST",
            dataType: "json",
            /*data: $('#form1').serialize(),*/
            data: {username: $(".name").val(), password: $(".password").val()},
            success: function (data) {
                    if(data.type=="success"){
                        window.location.href="management.html";
                    }else{
                        alert(data.content);
                    }
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.status);
                alert(XMLHttpRequest.readyState);
                alert(textStatus);
            }
        });
    }
</script>
</body>
</html>